//
// Created by 17775 on 2024/11/13.
//

#ifndef RAYCI_POINTING_STABILITY_H
#define RAYCI_POINTING_STABILITY_H

#include "RayCiPro_C.h"
#include <atomic>
#include <thread>
#include <QObject>
#include <windows.h>
#include <shellapi.h>

struct PointingStabilityDataBatch {
    std::vector<float> vecXRelativeTimes, vecXValues;
    std::vector<float> vecYRelativeTimes, vecYValues;
};

class Pointing_Stability : public QObject {
Q_OBJECT

signals:
    void getPointingStabilityData(const PointingStabilityDataBatch& data);
    void pointingStabilityMeasurementOver();

public slots:
    void exportReport();

public:
    ~Pointing_Stability();
    int _iPointingStabilityDocId = 0;
    void stopPointingStability();
    void clearPointingStability();
    void stopPointingStabilityThread();
    void setFrameSpan(int frames);
    void setEveryFrame(bool bEveryFrame);
    void setTimeSpan(double dTime);
    void setTimeStep(double dStep);
    void setFreeRunning(bool freeRunning);

    std::thread m_pointingStabilityThread;
    std::atomic<bool> getPointingStabilityDataThreadRunning = true;
    void getData();
    void getAllData();
    QString getDataUnit(int nChartType);
    double getStatisticalResult(int nChartType, int nColumn);
    double getAzimuthAngle();
    double getMaxDistance();
    double getWidthMajor();
    double getWidthMinor();

    // CentroidXY
    void getCentroidXYView();

    void closePointingStability(bool bWaitWhileClosing);
    void closeAllPointingStability(bool bWaitWhileClosing);
};


#endif //RAYCI_POINTING_STABILITY_H
